﻿/*
 * LINQ to LDAP
 * http://linqtoldap.codeplex.com/
 * 
 * Copyright Alan Hatter (C) 2010-2012
 * alan.hatter@gmail.com - http://hattercoding.blogspot.com/
 * 
 * This project is subject to licensing restrictions. Visit http://linqtoldap.codeplex.com/license for more information.
 */

using System;
using System.Collections.Generic;
using LinqToLdap.Helpers;

namespace LinqToLdap.Mapping
{
    internal class StandardObjectMapping<T> : ObjectMapping where T : class 
    {
        private readonly Ctor<T> _constructor;

        public StandardObjectMapping(string namingContext,
            IEnumerable<IPropertyMapping> propertyMappings, string objectCategory, IEnumerable<string> objectClass)
            : base(namingContext, propertyMappings, objectCategory, objectClass)
        {
            _constructor = DelegateBuilder.BuildCtor<T>();
        }

        public override bool IsForAnonymousType { get { return false; } }
        public override Type Type { get { return typeof(T); } }
        
        public override object Create(object[] parameters = null)
        {
            return _constructor();
        }
    }
}
